package com.kcwx.common.utils;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

public class BooleanJsonDeserializer extends JsonDeserializer<Integer> {
	@Override
	public Integer deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
			throws IOException, JsonProcessingException {
		Integer res = 0;
		try {
			if (jsonParser != null && jsonParser.getText() != null) {
				Boolean param = jsonParser.getBooleanValue();
				// 返回
				res = param ? 1 : 0;
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return res;
	}
}
